package com.zang.jvm;

/**
 * StackOverflowError 堆栈溢出测试
 * @author Zhang Qiang
 * @date 2019/12/12 15:57
 */
public class StackOverflowErrorAction {
    private int stackLength=1;

    public void stackLeak(){
        stackLength++;
        if (stackLength % 1000 == 0){
            System.out.println("stackLength:" + stackLength);
        }
        stackLeak();
    }

    public static void main(String[]args) {
        StackOverflowErrorAction oom = new StackOverflowErrorAction();
        try{
            oom.stackLeak();
        }catch(Throwable e){
            System.out.println("stack length：" + oom.stackLength);
            System.err.println("throw : " + e);
            return;
        }
    }
}
